// createRouter：创建router实例对象
// createWebHistory：创建history模式的路由对象

import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/views/Layout'
import Home from '@/views/Home/index.vue'
import Category from '@/views/Category'
import subCategory from '@/views/Category/subCategory.vue'
import Goods from '@/views/Goods'
import Playground from '@/views/Playground'
import Login from '@/views/Login'
import Cart from '@/views/Cart'
import Settlement from '@/views/settlement'
import Order from '@/views/Order'
import PayBack from '@/views/PayBack'
const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '',
        component: Home
      },
      {
        path: 'category/:id',
        name: 'category',
        component: Category
      },
      {
        path: 'category/sub/:id',
        component: subCategory
      },
      {
        path: 'goods/:id',
        component: Goods
      },
      {
        path: 'cart',
        component: Cart
      }
    ]
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/settle',
    component: Settlement
  },
  {
    name: 'order',
    path: '/order/:id',
    component: Order
  },
  {
    path: '/payback',
    component: PayBack
  },
  {
    path: '/play',
    component: Playground
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
